#include <iostream>
#include <signal.h>
#include <unistd.h>

using namespace std;
void fun(int sig)
{
    int n = alarm(5);
    cout << "get alarm" << "time:" << n <<endl;
}

int main()
{
    //alarm收到信号后默认退出进程，进行自定义信号捕捉
    signal(SIGALRM, fun);
    int n  =alarm(5);
    int cnt = 5;
    while(1)
    {
        cout << "process running" << endl;
        sleep(1);
    }
}